package models;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;

import play.data.validation.Required;
import play.db.jpa.Model;

@Entity
public class FMPAQuinquennal extends Model{
	
	@Required
	@ManyToOne
	public FMPA fmpa;
	
	@ManyToMany
	public List<Sequence> sequences;
	
	@Required
	public int annee;

	public FMPAQuinquennal(FMPA fmpa, int annee) {
		this.fmpa = fmpa;
		this.annee = annee;
		this.sequences = new ArrayList();
	}
	
	public void add(Sequence s){
		sequences.add(s);
	}
	
	public void remove(Sequence s){
		sequences.remove(s);
	}
	
	public boolean contientSequence(Sequence s){
		return sequences.contains(s);
	}
	
	public String toString(){
		return fmpa.toString();
	}
}